<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="申请编号" prop="applyNo">
        <el-input
            v-model="queryParams.applyNo"
            placeholder="请输入申请编号"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="需求状态" prop="applyState">
        <el-select class="w-40" v-model="queryParams.applyState" placeholder="请选择需求状态" clearable>
          <el-option
              v-for="dict in financingApplyType"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="省名称" prop="provinceName">
        <el-input
            v-model="queryParams.provinceName"
            placeholder="请输入省名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="市名称" prop="cityName">
        <el-input
            v-model="queryParams.cityName"
            placeholder="请输入市名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区名称" prop="areaName">
        <el-input
            v-model="queryParams.areaName"
            placeholder="请输入区名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" style="width: 308px">
        <el-date-picker
            v-model="daterangeCreateTime"
            value-format="YYYY-MM-DD"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="企业名称" prop="enterpriseName">
        <el-input
            v-model="queryParams.enterpriseName"
            placeholder="请输入企业名称"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="Plus"
            @click="handleAdd"
            v-hasPermi="['manage:demand:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            icon="Edit"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['manage:demand:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="Delete"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['manage:demand:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="Download"
            @click="handleExport"
            v-hasPermi="['manage:demand:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- Tab 切换栏 -->
    <el-tabs v-model="queryParams.applyState" @tab-change="handleQuery" class="mb8">
      <el-tab-pane label="全部" name=""></el-tab-pane>
      <el-tab-pane
          v-for="dict in financingApplyType"
          :key="dict.value"
          :label="dict.label"
          :name="dict.value"
      ></el-tab-pane>
    </el-tabs>
    <el-table v-loading="loading" border :data="demandList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="申请编号" align="center" prop="applyNo" width="180"/>
      <el-table-column label="申请方式" align="center" prop="applyWay" width="100">
        <template #default="scope">
          <dict-tag :options="whiteOrderType" :value="scope.row.applyWay"/>
        </template>
      </el-table-column>
      <el-table-column label="申请金额最小值" align="center" prop="applyAmountMin"/>
      <el-table-column label="申请金额最大值" align="center" prop="applyAmountMax"/>
      <el-table-column label="融资意向" align="center" prop="orientation"/>
      <el-table-column label="融资期限上限" align="center" prop="maturityMax"/>
      <el-table-column label="融资期限下限" align="center" prop="maturityMin"/>
      <el-table-column label="利率上限%" align="center" prop="rateMax"/>
      <el-table-column label="利率下限%" align="center" prop="rateMin"/>
      <el-table-column label="担保类型" align="center" prop="guaranteeType">
        <template #default="scope">
          <dict-tag :options="guarantee_type" :value="scope.row.guaranteeType"/>
        </template>
      </el-table-column>
      <el-table-column label="还款方式" align="center" prop="repaymentType" width="100">
        <template #default="scope">
          <dict-tag :options="repaymentType" :value="scope.row.repaymentType"/>
        </template>
      </el-table-column>
      <el-table-column label="到账时间类型" align="center" prop="arrivalTimeType" width="100">
        <template #default="scope">
          <dict-tag :options="expectedArrivalDate" :value="scope.row.arrivalTimeType"/>
        </template>
      </el-table-column>
      <el-table-column label="需求状态" align="center" prop="applyState">
        <template #default="scope">
          <dict-tag :options="financingApplyType" :value="scope.row.applyState"/>
        </template>
      </el-table-column>
      <el-table-column label="盈亏状态选项" align="center" prop="profitState"/>
      <el-table-column label="收入数据选项" align="center" prop="incomeData"/>
      <el-table-column label="纳税等级选项" align="center" prop="taxLevel"/>
      <el-table-column label="纳税金额选项" align="center" prop="taxAmount"/>
      <el-table-column label="之前贷款银行" align="center" prop="loanBankName"/>
      <el-table-column label="之前贷款银行-其他" align="center" prop="loanBankOther"/>
      <el-table-column label="当前贷款余额" align="center" prop="loanLeftAmount"/>
      <el-table-column label="抵押物标识" align="center" prop="collateralFlag">
        <template #default="scope">
          <dict-tag :options="pawnType" :value="scope.row.collateralFlag"/>
        </template>
      </el-table-column>
      <el-table-column label="省名称" align="center" prop="provinceName"/>
      <el-table-column label="市名称" align="center" prop="cityName"/>
      <el-table-column label="区名称" align="center" prop="areaName"/>
      <el-table-column label="终止理由" align="center" prop="reason"/>
      <el-table-column label="发起来源" align="center" prop="source"/>
      <el-table-column label="发起来源渠道" align="center" prop="sourceChannel"/>
      <el-table-column label="融资顾问" align="center" prop="financialAdvisor"/>
      <el-table-column label="融资顾问手机号" align="center" prop="financialAdvisorTell"/>
      <el-table-column label="联系人" align="center" prop="enterpriseContactor"/>
      <el-table-column label="联系人电话" align="center" prop="contactorTell" width="120"/>
      <el-table-column label="备注【融资取消理由其他】" align="center" prop="remarks"/>
      <el-table-column label="抵押房产类型 " align="center" prop="mortgageEstateType">
        <template #default="scope">
          <dict-tag :options="productPawn" :value="scope.row.mortgageEstateType"/>
        </template>
      </el-table-column>
      <el-table-column label="经营所在地省名称" align="center" prop="corrProvinceSiteName"/>
      <el-table-column label="经营所在地市名称" align="center" prop="corrCitySiteName"/>
      <el-table-column label="经营所在地区名称" align="center" prop="corrAreaSiteName"/>
      <el-table-column label="机构名称" align="center" prop="organizationName" width="200"/>
      <el-table-column label="站点名称" align="center" prop="siteName"/>
      <el-table-column label="产品名称" align="center" prop="productName" width="200"/>
      <el-table-column label="申请时间" width="120" align="center" prop="createTime" />
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="企业名称" align="center" prop="enterpriseName"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['manage:demand:edit']">修改
          </el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['manage:demand:remove']">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改企业融资需求对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="demandRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请编号" prop="applyNo">
          <el-input v-model="form.applyNo" placeholder="请输入申请编号"/>
        </el-form-item>
        <el-form-item label="申请方式" prop="applyWay">
          <el-select v-model="form.applyWay" placeholder="请选择申请方式">
            <el-option
                v-for="dict in whiteOrderType"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="申请金额最小值" prop="applyAmountMin">
          <el-input v-model="form.applyAmountMin" placeholder="请输入申请金额最小值"/>
        </el-form-item>
        <el-form-item label="申请金额最大值" prop="applyAmountMax">
          <el-input v-model="form.applyAmountMax" placeholder="请输入申请金额最大值"/>
        </el-form-item>
        <el-form-item label="融资意向" prop="orientation">
          <el-input v-model="form.orientation" placeholder="请输入融资意向"/>
        </el-form-item>
        <el-form-item label="融资期限上限" prop="maturityMax">
          <el-input v-model="form.maturityMax" placeholder="请输入融资期限上限"/>
        </el-form-item>
        <el-form-item label="融资期限下限" prop="maturityMin">
          <el-input v-model="form.maturityMin" placeholder="请输入融资期限下限"/>
        </el-form-item>
        <el-form-item label="利率上限%" prop="rateMax">
          <el-input v-model="form.rateMax" placeholder="请输入利率上限%"/>
        </el-form-item>
        <el-form-item label="利率下限%" prop="rateMin">
          <el-input v-model="form.rateMin" placeholder="请输入利率下限%"/>
        </el-form-item>
        <el-form-item label="担保类型" prop="guaranteeType">
          <el-select v-model="form.guaranteeType" placeholder="请选择担保类型">
            <el-option
                v-for="dict in guarantee_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="还款方式" prop="repaymentType">
          <el-select v-model="form.repaymentType" placeholder="请选择还款方式">
            <el-option
                v-for="dict in repaymentType"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="到账时间类型" prop="arrivalTimeType">
          <el-select v-model="form.arrivalTimeType" placeholder="请选择到账时间类型">
            <el-option
                v-for="dict in expectedArrivalDate"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="需求状态" prop="applyState">
          <el-select v-model="form.applyState" placeholder="请选择需求状态">
            <el-option
                v-for="dict in financingApplyType"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="盈亏状态选项" prop="profitState">
          <el-input v-model="form.profitState" placeholder="请输入盈亏状态选项"/>
        </el-form-item>
        <el-form-item label="收入数据选项" prop="incomeData">
          <el-input v-model="form.incomeData" placeholder="请输入收入数据选项"/>
        </el-form-item>
        <el-form-item label="纳税等级选项" prop="taxLevel">
          <el-input v-model="form.taxLevel" placeholder="请输入纳税等级选项"/>
        </el-form-item>
        <el-form-item label="纳税金额选项" prop="taxAmount">
          <el-input v-model="form.taxAmount" placeholder="请输入纳税金额选项"/>
        </el-form-item>
        <el-form-item label="之前贷款银行" prop="loanBankName">
          <el-input v-model="form.loanBankName" placeholder="请输入之前贷款银行"/>
        </el-form-item>
        <el-form-item label="之前贷款银行-其他" prop="loanBankOther">
          <el-input v-model="form.loanBankOther" placeholder="请输入之前贷款银行-其他"/>
        </el-form-item>
        <el-form-item label="当前贷款余额" prop="loanLeftAmount">
          <el-input v-model="form.loanLeftAmount" placeholder="请输入当前贷款余额"/>
        </el-form-item>
        <el-form-item label="省站点ID" prop="provinceSiteId">
          <el-input v-model="form.provinceSiteId" placeholder="请输入省站点ID"/>
        </el-form-item>
        <el-form-item label="抵押物标识" prop="collateralFlag">
          <el-select v-model="form.collateralFlag" placeholder="请选择抵押物标识">
            <el-option
                v-for="dict in pawnType"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="省名称" prop="provinceName">
          <el-input v-model="form.provinceName" placeholder="请输入省名称"/>
        </el-form-item>
        <el-form-item label="市站点ID" prop="citySiteId">
          <el-input v-model="form.citySiteId" placeholder="请输入市站点ID"/>
        </el-form-item>
        <el-form-item label="市名称" prop="cityName">
          <el-input v-model="form.cityName" placeholder="请输入市名称"/>
        </el-form-item>
        <el-form-item label="区站点ID" prop="areaSiteId">
          <el-input v-model="form.areaSiteId" placeholder="请输入区站点ID"/>
        </el-form-item>
        <el-form-item label="区名称" prop="areaName">
          <el-input v-model="form.areaName" placeholder="请输入区名称"/>
        </el-form-item>
        <el-form-item label="终止理由" prop="reason">
          <el-input v-model="form.reason" placeholder="请输入终止理由"/>
        </el-form-item>
        <el-form-item label="发起来源" prop="source">
          <el-input v-model="form.source" placeholder="请输入发起来源"/>
        </el-form-item>
        <el-form-item label="发起来源渠道" prop="sourceChannel">
          <el-input v-model="form.sourceChannel" placeholder="请输入发起来源渠道"/>
        </el-form-item>
        <el-form-item label="融资顾问" prop="financialAdvisor">
          <el-input v-model="form.financialAdvisor" placeholder="请输入融资顾问"/>
        </el-form-item>
        <el-form-item label="融资顾问手机号" prop="financialAdvisorTell">
          <el-input v-model="form.financialAdvisorTell" placeholder="请输入融资顾问手机号"/>
        </el-form-item>
        <el-form-item label="联系人" prop="enterpriseContactor">
          <el-input v-model="form.enterpriseContactor" placeholder="请输入联系人"/>
        </el-form-item>
        <el-form-item label="联系人电话" prop="contactorTell">
          <el-input v-model="form.contactorTell" placeholder="请输入联系人电话"/>
        </el-form-item>
        <el-form-item label="备注【融资取消理由其他】" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注【融资取消理由其他】"/>
        </el-form-item>
        <el-form-item label="删除标识" prop="deleted">
          <el-input v-model="form.deleted" placeholder="请输入删除标识"/>
        </el-form-item>
        <el-form-item label="版本" prop="version">
          <el-input v-model="form.version" placeholder="请输入版本"/>
        </el-form-item>
        <el-form-item label="抵押房产类型 " prop="mortgageEstateType">
          <el-select v-model="form.mortgageEstateType" placeholder="请选择抵押房产类型 ">
            <el-option
                v-for="dict in productPawn"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="抵押物房产所在地" prop="mortgageEstateAddress">
          <el-input v-model="form.mortgageEstateAddress" placeholder="请输入抵押物房产所在地"/>
        </el-form-item>
        <el-form-item label="抵押物房产所在省" prop="mortgageEstateProvince">
          <el-input v-model="form.mortgageEstateProvince" placeholder="请输入抵押物房产所在省"/>
        </el-form-item>
        <el-form-item label="抵押物房产所在市" prop="mortgageEstateCity">
          <el-input v-model="form.mortgageEstateCity" placeholder="请输入抵押物房产所在市"/>
        </el-form-item>
        <el-form-item label="抵押物房产所在区" prop="mortgageEstateArea">
          <el-input v-model="form.mortgageEstateArea" placeholder="请输入抵押物房产所在区"/>
        </el-form-item>
        <el-form-item label="经营所在省编码" prop="corrProvinceSiteId">
          <el-input v-model="form.corrProvinceSiteId" placeholder="请输入经营所在省编码"/>
        </el-form-item>
        <el-form-item label="经营所在地省名称" prop="corrProvinceSiteName">
          <el-input v-model="form.corrProvinceSiteName" placeholder="请输入经营所在地省名称"/>
        </el-form-item>
        <el-form-item label="经营所在地市编码" prop="corrCitySiteId">
          <el-input v-model="form.corrCitySiteId" placeholder="请输入经营所在地市编码"/>
        </el-form-item>
        <el-form-item label="经营所在地市名称" prop="corrCitySiteName">
          <el-input v-model="form.corrCitySiteName" placeholder="请输入经营所在地市名称"/>
        </el-form-item>
        <el-form-item label="经营所在地区编码" prop="corrAreaSiteId">
          <el-input v-model="form.corrAreaSiteId" placeholder="请输入经营所在地区编码"/>
        </el-form-item>
        <el-form-item label="经营所在地区名称" prop="corrAreaSiteName">
          <el-input v-model="form.corrAreaSiteName" placeholder="请输入经营所在地区名称"/>
        </el-form-item>
        <el-form-item label="机构名称" prop="organizationName">
          <el-input v-model="form.organizationName" placeholder="请输入机构名称"/>
        </el-form-item>
        <el-form-item label="站点ID" prop="siteId">
          <el-input v-model="form.siteId" placeholder="请输入站点ID"/>
        </el-form-item>
        <el-form-item label="本地站点编号" prop="siteCode">
          <el-input v-model="form.siteCode" placeholder="请输入本地站点编号"/>
        </el-form-item>
        <el-form-item label="站点名称" prop="siteName">
          <el-input v-model="form.siteName" placeholder="请输入站点名称"/>
        </el-form-item>
        <el-form-item label="企业id" prop="enterpriseId">
          <el-input v-model="form.enterpriseId" placeholder="请输入企业id"/>
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称"/>
        </el-form-item>
        <el-form-item label="优惠券id" prop="ticketId">
          <el-input v-model="form.ticketId" placeholder="请输入优惠券id"/>
        </el-form-item>
        <el-form-item label="企业白名单id" prop="wlEnterpriseId">
          <el-input v-model="form.wlEnterpriseId" placeholder="请输入企业白名单id"/>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注"/>
        </el-form-item>
        <el-form-item label="企业名称" prop="enterpriseName">
          <el-input v-model="form.enterpriseName" placeholder="请输入企业名称"/>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Demand">
import {listDemand, getDemand, delDemand, addDemand, updateDemand} from "@/api/manage/demand"

const {proxy} = getCurrentInstance()
const {
  guarantee_type,
  productPawn,
  whiteOrderType,
  expectedArrivalDate,
  repaymentType,
  pawnType,
  financingApplyType
} = proxy.useDict('guarantee_type', 'productPawn', 'whiteOrderType', 'expectedArrivalDate', 'repaymentType', 'pawnType', 'financingApplyType')

const demandList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
const daterangeCreateTime = ref([])

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    applyNo: null,
    applyState: "",
    provinceName: null,
    cityName: null,
    areaName: null,
    createTime: null,
    beginCreateTime: null,
    endCreateTime: null,
    enterpriseName: null
  },
  rules: {}
})

const {queryParams, form, rules} = toRefs(data)

/** 查询企业融资需求列表 */
function getList() {
  loading.value = true
  queryParams.value.params = {}
  if (null != daterangeCreateTime && '' != daterangeCreateTime) {
    queryParams.value.beginCreateTime = daterangeCreateTime.value[0]
    queryParams.value.endCreateTime = daterangeCreateTime.value[1]
  }
  listDemand(queryParams.value).then(response => {
    demandList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    creditCodeDelete: null,
    applyNo: null,
    applyWay: null,
    applyAmountMin: null,
    applyAmountMax: null,
    orientation: null,
    maturityMax: null,
    maturityMin: null,
    rateMax: null,
    rateMin: null,
    guaranteeType: null,
    repaymentType: null,
    arrivalTimeType: null,
    applyState: "",
    profitState: null,
    incomeData: null,
    taxLevel: null,
    taxAmount: null,
    loanBankName: null,
    loanBankOther: null,
    loanLeftAmount: null,
    provinceSiteId: null,
    collateralFlag: null,
    provinceName: null,
    citySiteId: null,
    cityName: null,
    areaSiteId: null,
    areaName: null,
    reason: null,
    source: null,
    sourceChannel: null,
    financialAdvisor: null,
    financialAdvisorTell: null,
    enterpriseContactor: null,
    contactorTell: null,
    remarks: null,
    deleted: null,
    createTime: null,
    updateTime: null,
    version: null,
    mortgageEstateType: null,
    mortgageEstateAddress: null,
    mortgageEstateProvince: null,
    mortgageEstateCity: null,
    mortgageEstateArea: null,
    productId: null,
    corrProvinceSiteId: null,
    corrProvinceSiteName: null,
    corrCitySiteId: null,
    corrCitySiteName: null,
    corrAreaSiteId: null,
    corrAreaSiteName: null,
    organizationName: null,
    siteId: null,
    siteCode: null,
    siteName: null,
    enterpriseId: null,
    productName: null,
    ticketId: null,
    wlEnterpriseId: null,
    createBy: null,
    updateBy: null,
    remark: null,
    enterpriseName: null
  }
  proxy.resetForm("demandRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  console.log("Tab changed, triggering query..."); // 添加日志
  queryParams.value.pageNum = 1
  getList()
}


/** 重置按钮操作 */
function resetQuery() {
  // 仅重置搜索表单的字段，但保留 applyState（由 Tab 控制）
  const savedApplyState = queryParams.value.applyState
  daterangeCreateTime.value = []
  proxy.resetForm("queryRef")
  queryParams.value.applyState = savedApplyState // 恢复 applyState
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加企业融资需求"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _id = row.id || ids.value
  getDemand(_id).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改企业融资需求"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["demandRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateDemand(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addDemand(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value
  proxy.$modal.confirm('是否确认删除企业融资需求编号为"' + _ids + '"的数据项？').then(function () {
    return delDemand(_ids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {
  })
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('manage/demand/export', {
    ...queryParams.value
  }, `demand_${new Date().getTime()}.xlsx`)
}

getList()
</script>
